package cn.zyq.ykb.controller.mgt.user;

import cn.zyq.ykb.beans.task.bo.UserCashAuditBo;
import cn.zyq.ykb.beans.user.UserCash;
import cn.zyq.ykb.beans.user.bo.UserBalanceBo;
import cn.zyq.ykb.service.user.UserCashService;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户-提现记录Controller
 *
 * @author SystemAuth
 * @date 2023-05-23
 */

@RestController(value = "MgtUserCashController")
@RequestMapping("/mgt/userCash")
@Api(tags = "用户-提现记录接口")
public class UserCashController extends BaseController {

    @Autowired
    private UserCashService userCashService;

    /**
     * 查询用户-提现记录列表
     */
    @ApiOperation(value = "列表", response = UserCash.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.userCashService.selectUserCashList(pageParam);
    }

    /**
     * 导出配置- 道具列表
     */
    @ApiOperation(value = "导出")
    @Log(title = "用户-提现记录" , businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserCash userCash) {
        List<UserCash> list = userCashService.selectUserCashList(userCash);
        ExcelUtil<UserCash> util = new ExcelUtil<UserCash>(UserCash. class);
        util.exportExcel(response, list, "用户-提现记录数据");
    }

    @ApiOperation(value = "提现审核", response = UserCash.class)
    @PostMapping("/audit")
    public Object audit(@RequestBody UserCashAuditBo bo) {
        return this.userCashService.audit(bo,this.getLoginSysAdmin(),this.request);
    }

    @ApiOperation(value = "新增提现", response = UserCash.class)
    @PostMapping("/add")
    public Object add(@RequestBody UserBalanceBo bo) {
        return this.userCashService.add(bo);
    }
    @ApiOperation(value = "删除提现", response = UserCash.class)
    @GetMapping("/delete/{userBalanceID}")
    public Object delete(@PathVariable("userBalanceID") Integer userBalanceID ) {
        return this.userCashService.delete(userBalanceID);
    }
}
